/**
 * 从指定的响应式对象中排除一些属性组成一个计算属性
 * @param obj
 * @param keys
 * @returns
 */
export function omitReactive<T extends object, K extends keyof T>(
  obj: T,
  keys: K[]
) {
  return computed(() => {
    const val = {} as any
    Object.keys(obj).forEach(key => {
      if (keys.includes(key as K)) {
        return
      }
      val[key] = obj[key]
    })
    return val as Omit<T, K>
  })
}

/**
 * 从指定的响应式对象中挑选一些属性组成一个计算属性
 * @param obj
 * @param keys
 * @returns
 */
export function pickReactive<T extends object, K extends keyof T>(
  obj: T,
  keys: K[]
) {
  return computed(() => {
    const val = {} as any
    Object.keys(obj).forEach(key => {
      if (!keys.includes(key as K)) {
        return
      }
      val[key] = obj[key]
    })
    return val as Pick<T, K>
  })
}
